package com.mes.inventory.domain;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Employee;
import com.mes.basicdata.domain.Part;
import com.mes.basicdata.domain.TypesData;
import com.mes.common.domain.BasicModel;

/**
 * <p>
 * Warebin柜位
 * </p>
 */
@Entity()
//@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "I_WAREBIN")
//@BatchSize(size=10)
//@Lazy(value=true)
//@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Warebin extends BasicModel
{
	@Id
	@GenericGenerator(name = "warebinUid", strategy = "assigned")
	@Column(name="UNIQUEID")
	protected String warebinUid;
	
	@Column(name="WAREHOUSEID",length=50)
	protected String warehouseUid;
	
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="WAREHOUSEID",insertable=false,updatable=false)
	protected Warehouse warehouse;

	@Column(name="BINID",length=50)
	protected String binID;
	
	public String getBinID() {
		return binID;
	}

	public void setBinID(String binID) {
		this.binID = binID;
	}
	@Column(name="BINNAME",length=50)
	protected String binName;
	
	@Column(name="MAXBINQTY",precision=10,scale=4)
	protected Float maxBinQty;

	@Column(name="BINMANAGER",length=50)
	protected String binManagerUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="BINMANAGER",insertable=false,updatable=false)
	protected Employee binManager;
	
	@Column(name="BINTYPE",length=50)
	protected String binType;
	
//	@ForeignKey(name="null")
//	@ManyToOne(fetch=FetchType.LAZY)
//	@JoinColumnsOrFormulas(value={
//			@JoinColumnOrFormula(column=@JoinColumn(name="BINTYPE",referencedColumnName="ID",nullable=true,insertable=false,updatable=false)),
//			@JoinColumnOrFormula(formula=@JoinFormula(value="'bintype'", referencedColumnName="TYPESNAME"))
//	})
//	protected TypesData binTypeDesc;

	@Column(name="PARENTBINID",length=50)
	protected String parentBinUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="PARENTBINID",insertable=false,updatable=false)
	protected Warebin parentWarebin;

	@Column(name="DEPTID",length=50)
	protected String deptUid;
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEPTID",insertable=false,updatable=false)
	protected Dept dept;

	// Constructors

	/** default constructor */
	public Warebin()
	{
	}

	@Override
	public String getUuid()
	{
		return this.warebinUid;
	}
	@Override
	public void setUuid(String uuid)
	{
		this.warebinUid = uuid;
	}
	
	public String getWarebinUid()
	{
		return warebinUid;
	}
	public void setWarebinUid(String warebinUid)
	{
		this.warebinUid = warebinUid;
	}
	
	public String getWarehouseUid()
	{
		return warehouseUid;
	}
	public void setWarehouseUid(String warehouseUid)
	{
		this.warehouseUid = warehouseUid;
	}

	public Warehouse getWarehouse()
	{
		return warehouse;
	}
	public void setWarehouse(Warehouse warehouse)
	{
		this.warehouse = warehouse;
	}

	public String getBinName()
	{
		return binName;
	}
	public void setBinName(String binName)
	{
		this.binName = binName;
	}

	public Float getMaxBinQty()
	{
		return maxBinQty;
	}
	public void setMaxBinQty(Float maxBinQty)
	{
		this.maxBinQty = maxBinQty;
	}

	public String getBinManagerUid()
	{
		return binManagerUid;
	}
	public void setBinManagerUid(String binManagerUid)
	{
		this.binManagerUid = binManagerUid;
	}

	public Employee getBinManager()
	{
		return binManager;
	}
	public void setBinManager(Employee binManager)
	{
		this.binManager = binManager;
	}

	public String getBinType()
	{
		return binType;
	}
	public void setBinType(String binType)
	{
		this.binType = binType;
	}

	public String getParentBinUid()
	{
		return parentBinUid;
	}
	public void setParentBinUid(String parentBinUid)
	{
		this.parentBinUid = parentBinUid;
	}

	public Warebin getParentWarebin()
	{
		return parentWarebin;
	}
	public void setParentWarebin(Warebin parentWarebin)
	{
		this.parentWarebin = parentWarebin;
	}

	public String getDeptUid()
	{
		return deptUid;
	}
	public void setDeptUid(String deptUid)
	{
		this.deptUid = deptUid;
	}

	public Dept getDept()
	{
		return dept;
	}
	public void setDept(Dept dept)
	{
		this.dept = dept;
	}

}